package com.scedu.spring5.service;

import com.scedu.spring5.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(propagation = Propagation.REQUIRED,
        isolation = Isolation.SERIALIZABLE,
        timeout = 10
)
public class AccountService {
    //注入Dao
    @Autowired
    private AccountDao accountDao;


    //转账的方法
    public void transMoney(){
        //lucy 少100
        accountDao.reduceMoney();
        //模拟出现异常
        //int i=10/0;

        //marry多100
        accountDao.addMoney();


    }
}
